## -*- coding: utf-8 -*-
<%inherit file="/derived/section/section_base.html"/>
<%namespace file="/component/navigation.html" import="selector" />
<%namespace file="/component/utils.html" import="*" />
<%namespace file="/component/post.html" import="blog_info" />
<%! 
    from pythonblog.service.content_service import get_new_posts, is_user_digged, get_post
%>

${selector()}

% if len(c.posts):
    %for post in c.posts :
    ${post_abstract(post)}
    %endfor

    % if c.posts.last_page > 1:
    <div style="padding-top:20px;"></div>
    ${paginate(c.posts, request.environ.get('PATH_INFO'))}
    % endif

% endif

% if len(c.post_ids):
    %for element in c.post_ids :
    <%
      extra = None
      hint = None
      post = get_post(element.id)
      if c.menu.rank_type == 'total':
          extra = post.get_total_scroes()
          hint = post.get_total_post_hint()
      if c.menu.rank_type == 'hot':
          c_date = element.c_date
          v_date = element.v_date
          if c_date and v_date:
              if c_date >= v_date:
                  extra = post.get_comment_extra()
              else:
                  extra = post.get_dig_extra()
          elif c_date:
              extra = post.get_comment_extra()
          elif v_date:
              extra = post.get_dig_extra()
      
    %>
    ${post_abstract(post, extra, hint)}
    %endfor    
    % if c.post_ids.last_page > 1:
    <div style="padding-top:20px;"></div>
    ${paginate(c.post_ids, request.environ.get('PATH_INFO'))}
    % endif

% endif


<%def name="post_abstract(post, extra=None, hint=None)">
<div class="blog clearfix">
    ${digg(post)}
    <div class="content">
        <div class="title">
            <div style="float: right;"> 文 / ${link_for_user(post.user.userName, post.user.author)}</div>
            <div class="title_url">
              ${link_for_post(post)}
            </div>
        </div>
        <div style="padding-bottom: 5px;">
            <div style="float: right; padding-left: 1px;"><div class="logo">${link_for_user_logo(post.user)}</div></div>
            ${post.abstract}
        </div>
        <div class="blog_info">
            ${blog_info(post, False, extra, hint)}
        </div>
    </div>
</div>
</%def>

